package com.dragon.modules.yuegou.enums.code;

import com.dragon.common.constant.enums.IBusinessCode;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 支付业务状态码 已280开头
 *
 * @author cz@100yueoo.com
 *
 */
public enum PayCode implements IBusinessCode {
	APPID_ERROR(28001, "appid错误或者后台未配置该信息"),

	MOBILE_IS_EMPTY(28002, "手机号为空"),

	OPENID_IS_EMPTY(28003, "openid为空"),

	APPID_IS_EMPTY(28004, "APPID为空"),

	VALIDATECODE_IS_EMPTY(28005, "验证码为空"),

	MOBILE_IS_REPEAT(28007, "手机号重复"),

	MEMBERID_IS_EMPTY(28008, "会员id为空"),

	BUSD_IS_NOT_EXIST(28009, "商圈不存在"),

	ORDER_NO_LENGTH_ERROR(28010, "订单号不能大于32位小于6位"),

	ORDER_NO_IS_EMPTY(28011, "订单号为空"),

	ORDER_NO_HEAD_ERROR(28012, "订单号必须以4738开头"),

	UMS_PAY_URL_EMPTY(28013, "银联支付接口地址配置为空"),

	PAY_SOURCE_EMPTY(28014, "支付来源为空"),

	PAY_INVALID_CODE(28015, "无效码"),

	PAY_NOT_OPEN(28016, "未开启扫码付"),

	MERCHANT_IS_EMPTY(28017, "商铺id为空"),

	MERCHANT_IS_NOT_EXIST(28018, "商铺不存在"),

	VALIDATE_CODE_IS_EMPTY(28019, "验证码为空"),

	MOBILE_IS_NOT_EXIST(28020, "手机号不存在"),

	PASSWORD_IS_ERROR(28021, "账号密码错误"),

	TWICE_PASSWORD_INCONSISTENT(28022, "两次密码输入不一致"),

	ORDER_SATSUS_ERROR(28023, "订单状态错误，不能支付"),

	CARDLIST_EMPTY(28024, "悦卡列表为空"),

	SOURCE_IS_EMPTY(28025, "来源为空"),

	PAY_MONEY_ERROR(28026, "支付金额不对"),

	MEMBER_NOR_OPENID(28027, "会员没有openid"),

	ALIPAY_ERROR(28028, "支付宝预支付出错，请联系管理员"),

	BANK_EMPTY(28029, "商户未绑定银行卡，请先绑定"),

	ORDER_STATUS_ERROR(28030, "只有未支付订单才能支付"),

	PAY_MONEY_MINI(28031, "支付金额必须大于0"),

	PAY_ERROR(28032, "支付出错，请联系管理员"),

	WITHDRAW_ERROR(28033, "支付出错，请联系管理员"),

	INVALID_YUE_CARD_EXISTS(28034, "悦卡id中存在无效悦卡"),

	YUE_CARD_ID_EXISTS(28035, "悦卡id中存在重复id"),

	PAY_STATUS_ERROR(28036, "未支付，不能退款"),

	GOODS_USED(28037, "已使用，不能退款"),

	UNEXPIRED(28038, "未过期，不能退款"),

	LOGIN_ERROR(28039, "登录失败"),

	RETUND_MONEY_MINI(28040, "退款金额必须大于0"),
	
	NO_PAYMENT_RECORD(28041, "退款未找到支付记录"),
	NO_FOUND_RELEVANT_BANK_CARD_INFORMATION(28042, "未找到相关银行卡信息！"),

	NO_PAY_YUECARD(28043, "该商品不支持悦卡支付"),

	REFUND_ERROR(28044, "退款失败"),
	
	PASSWORD_FORMAT_ERROR(28045, "密码格式错误"),
	
	ORDER_STATUS_CLOSE(28046, "订单已关闭"),
	
	OLD_PASSWORD_IS_ERROR(28047, "旧密码错误"),
	PAY_IS_NOT_USED_COUPON(28048, "使用优惠券后不能用悦卡支付"),
	WX_LOGIN_INFO_ERROR(28049, "微信登陆信息错误"),
	MOBILE_IS_HAS_BEEN_REGISTERED(28050, "该手机号码已被注册"),
	CONFIRM_PASSWORD_IS_EMPTY(28052, "确认密码不能为空"),
	PASSWORD_INCONSISTENCY(28053, "两次输入密码不一致！"),
	CARD_NO_IS_EMPTY(28054, "卡号为空"),
	CARD_PWD_IS_EMPTY(28055, "卡密码为空"),
	NO_CAN_PAY(28056, "不支持该卡消费"),
	MEMBER_CARD_ID_IS_EMPTY(28057, "会员卡id为空"),
	CARD_ID_IS_EXIST(28058, "悦卡不存在"),
	WITHDRAW_AMOUNT_ERROR(28059, "提现金额不能少于0.3元"),
	WITHDRAW_AMOUNT_ERROR1(28060, "微信支付官方限制,每人每天提现金额不能多于500元"),
	ENCODE_ERROR(28061, "识别失败，请重新识别"),


	PAY_PASSWORD_IS_ERROR(99999, "支付密码错误"),
	;


	private final Integer code;

	private final String message;

	private PayCode(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	@Override
	public Integer getCode() {
		return code;
	}

	@Override
	public String getMessage() {
		return message;
	}

	/**
	 * 把code转化为ResponseCode枚举
	 *
	 * @param code
	 *            代码
	 * @return
	 */
	public static PayCode from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for ResponseCode
	 */
	private static final Map<Integer, PayCode> CODE_MAP = Stream.of(PayCode.values())
			.collect(Collectors.toMap(PayCode::getCode, e -> e));
}
